# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from tortoise import fields
from kernels.model import DbModel


class RechargeOrderModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    user_id = fields.IntField(null=False, default=0, description="用户ID")
    package_id = fields.IntField(null=False, default=0, description="充值套餐")
    order_sn = fields.CharField(null=False, max_length=64, default="", description="订单编号")
    terminal = fields.SmallIntField(null=False, default=0, description="来源平台")
    pay_way = fields.SmallIntField(null=False, default=0, description="支付方式: [2=微信支付, 3=支付宝支付]")
    pay_status = fields.SmallIntField(null=False, default=0, description="支付状态: [0=待支付, 1=已支付]")
    refund_status = fields.SmallIntField(null=False, default=0, description="退款状态: [0=未退款,1=退款中 2=成功, 3=失败]")
    order_amount = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="订单金额")
    paid_amount = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="实付金额")
    points_num = fields.IntField(null=False, default=0, description="积分数量")
    train_num = fields.IntField(null=False, default=0, description="训练组数")
    robot_num = fields.IntField(null=False, default=0, description="智能体数")
    know_num = fields.IntField(null=False, default=0, description="知识库数")
    mcp_num = fields.IntField(null=False, default=0, description="MCP数")
    transaction_id = fields.CharField(null=False, max_length=200, default="", description="交易流水号")
    snapshot = fields.TextField(null=False, default="", description="订单快照")
    is_delete = fields.SmallIntField(null=False, default=0, description="是否删除: [0=否, 1=是]")
    pay_time = fields.IntField(null=False, default=0, description="支付时间")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")
    delete_time = fields.IntField(null=False, default=0, description="删除时间")

    class Meta:
        table_description = "充值订单表"
        table = DbModel.table_prefix("recharge_order")


class RechargePackageModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    name = fields.CharField(null=False, max_length=100, default="", description="套餐名称")
    tags = fields.CharField(null=False, max_length=100, default="", description="套餐标签")
    sell_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="销售价格")
    line_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="划线价格")
    points_num = fields.IntField(null=False, default=0, description="积分数量")
    train_num = fields.IntField(null=False, default=0, description="训练组数量")
    robot_num = fields.IntField(null=False, default=0, description="智能体数量")
    know_num = fields.IntField(null=False, default=0, description="知识库数量")
    mcp_num = fields.IntField(null=False, default=0, description="MCP数量")
    sort = fields.IntField(null=False, default=0, description="排序编号")
    is_disable = fields.SmallIntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    is_delete = fields.SmallIntField(null=False, default=0, description="是否删除: [0=否, 1=是]")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")
    delete_time = fields.IntField(null=False, default=0, description="删除时间")

    class Meta:
        table_description = "充值套餐表"
        table = DbModel.table_prefix("recharge_package")


class SubscribeOrderModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    user_id = fields.IntField(null=False, default=0, description="用户ID")
    admin_id = fields.IntField(null=False, default=0, description="管理ID")
    package_id = fields.IntField(null=False, default=0, description="套餐ID")
    pricing_id = fields.IntField(null=False, default=0, description="定价ID")
    order_sn = fields.CharField(null=False, max_length=64, default="", description="订单编号")
    terminal = fields.SmallIntField(null=False, default=0, description="来源平台")
    pay_way = fields.SmallIntField(null=False, default=0, description="支付方式: [2=微信支付, 3=支付宝支付]")
    pay_status = fields.SmallIntField(null=False, default=0, description="支付状态: [0=待支付, 1=已支付]")
    refund_status = fields.SmallIntField(null=False, default=0, description="退款状态: [0=未退款,1=退款中 2=成功, 3=失败]")
    source_client = fields.SmallIntField(null=False, default=1, description="来源平台: [1=用户,2=后台]")
    order_amount = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="订单金额")
    paid_amount = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="实付金额")
    transaction_id = fields.CharField(null=False, max_length=200, default="", description="交易流水号")
    snapshot = fields.TextField(null=False, default="", description="订单快照")
    is_delete = fields.SmallIntField(null=False, default=0, description="是否删除: [0=否, 1=是]")
    package_end_time = fields.IntField(null=False, default=0, description="套餐到期时间")
    pay_time = fields.IntField(null=False, default=0, description="支付时间")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")
    delete_time = fields.IntField(null=False, default=0, description="删除时间")

    class Meta:
        table_description = "订阅订单表"
        table = DbModel.table_prefix("subscribe_order")


class SubscribePackageModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    name = fields.CharField(null=False, max_length=100, default="", description="套餐名称")
    description = fields.CharField(null=False, max_length=500, default="", description="套餐描述")
    train_num = fields.IntField(null=False, default=0, description="训练条数")
    robot_num = fields.IntField(null=False, default=0, description="智能体数")
    know_num = fields.IntField(null=False, default=0, description="知识库数")
    mcp_num = fields.IntField(null=False, default=0, description="MCP数")
    min_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="最高售价")
    max_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="最低售价")
    sort = fields.IntField(null=False, default=0, description="排序编号")
    is_builtin = fields.SmallIntField(null=False, default=0, description="系统内置: [0=否, 1=是]")
    is_disable = fields.SmallIntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    is_delete = fields.SmallIntField(null=False, default=0, description="是否删除: [0=否, 1=是]")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")
    delete_time = fields.IntField(null=False, default=0, description="删除时间")

    class Meta:
        table_description = "订阅套餐表"
        table = DbModel.table_prefix("subscribe_package")


class SubscribePricingModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    package_id = fields.IntField(null=False, default=0, description="套餐ID")
    tags = fields.CharField(null=False, max_length=100, default="", description="价格标签")
    calendar = fields.CharField(null=False, max_length=10, default="", description="时长类型: [day,month,year,perpetual")
    duration = fields.SmallIntField(null=False, default=0, description="套餐时长")
    give_points = fields.SmallIntField(null=False, default=0, description="赠送积分")
    sell_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="销售价格")
    line_price = fields.DecimalField(null=False, max_digits=10, decimal_places=2, default=0, description="划线价格")
    sort = fields.IntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    is_builtin = fields.SmallIntField(null=False, default=0, description="系统内置: [0=否, 1=是]")
    is_disable = fields.SmallIntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    is_delete = fields.SmallIntField(null=False, default=0, description="是否删除: [0=否, 1=是]")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")
    delete_time = fields.IntField(null=False, default=0, description="删除时间")

    class Meta:
        table_description = "订阅限制表"
        table = DbModel.table_prefix("subscribe_pricing")


class SubscribePrivilegeModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    package_id = fields.IntField(null=False, default=0, description="套餐ID")
    scene = fields.CharField(null=False, max_length=30, default="", description="套餐场景: [chat,vector,draws,music]")
    marks = fields.CharField(null=False, max_length=100, default="", description="渠道标记: [模型标记/应用标记]")
    daily_limit = fields.IntField(null=False, default=0, description="每日免费次数")
    is_disable = fields.SmallIntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")

    class Meta:
        table_description = "订阅限制表"
        table = DbModel.table_prefix("subscribe_privilege")


class SubscribeSpecificsModel(DbModel):
    id = fields.IntField(pk=True, unsigned=True, description="主键")
    package_id = fields.IntField(null=False, default=0, description="套餐ID")
    name = fields.CharField(null=False, max_length=100, default="", description="权益名称")
    description = fields.CharField(null=False, max_length=200, default="", description="权益描述")
    sort = fields.IntField(null=False, default=0, description="排序编号")
    is_support = fields.SmallIntField(null=False, default=0, description="是否支持: [0=否, 1=是]")
    is_disable = fields.SmallIntField(null=False, default=0, description="是否禁用: [0=否, 1=是]")
    create_time = fields.IntField(null=False, default=0, description="创建时间")
    update_time = fields.IntField(null=False, default=0, description="更新时间")

    class Meta:
        table_description = "订阅描述表"
        table = DbModel.table_prefix("subscribe_specifics")
